<form action="<%= tabs_competition_path(@competition, 'tasks') %>" method="get" id="form_ltaskcfilter">
  <%= hidden_field_tag :user_id, params[:user_id] %>
  <%= hidden_field_tag :filter, params[:filter] %>
</form>
<div class="left" style="width:220px">
  <div class="area">
    <ul class="filter-list">
    <%= task_user_id_entry_inner '所有人', Task.count, '' %>
    <% User.all.each do |user| %>
      <%= task_user_id_entry user %>
    <% end %>
    <ul>
  </div>
</div>

<div class="right" style="width:510px;">
  <div>
    <div class="button-group tasks-filter-buttons left">
      <%= task_filter_button '全部', '' %>
      <%= task_filter_button '已完成', 'finished' %>
      <%= task_filter_button '未完成', 'unfinished' %>
      <%= task_filter_button '未指定', 'unspecified' %>
    </div>
    <div class="right">
      <a class="button primary" href="<%= tabs_competition_path(@competition, 'tasks', filter: 'new') %>">新任务</a>
    </div>
    <div class="clear">
  </div>
  <div id="div_ltask" class="bar">
    <% if params[:filter] == 'new' || task_scope_display.empty? %>
      <%= render partial: 'tasks/create',
          locals: { competition: @competition } %>
    <% else %>

      <ul class="list-group">
        <% task_scope_display.each do |task| %>
          <li class="list-group-item">
            <h4 class="left"><%= link_to task.title, task %></h4>
            <div class="right list-group-item-meta"><%= task.assigned_to.nil? ? '未指派' : "指派给#{task.assigned_to.name_display}" %></div>
            <div class="clear"></div>
            <span class="list-group-item-meta">
              <%= task.finished_at.nil? ? 
                (task.due.nil? ? '未指定时限' : "#{date_text(task.due)} 截止")
                 : "已于 #{date_text(task.finished_at)} 完成" %>
            </span>
          </li>
        <% end %>
      </ul>
    <% end %>

    <p><%# js_tag '新任务', { switch: 'form_tasknc' } %></p>
      <%# render partial: 'tasks/create',
          locals: { competition: @competition } %>
    </div>
  </div>
</div>